package com.information.manage.basic.model.query;

import com.information.manage.basic.common.utils.AESIVUtil;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;

@Data
@ApiModel("用户登录参数")
public class LoginQuery {

    @ApiModelProperty(value = "用户名", required = true)
    private String username;

    @ApiModelProperty(value = "密码", required = true)
    private String password;

    @ApiModelProperty(value = "用于AES解码的iv", required = false)
    private String iv;

    public String getPassword() {
        // 对密码进行解码
        String ivValue = getIv();
        if (StringUtils.isEmpty(ivValue)) return password; // 不存在iv值的即暂不需要支持加密的
        String decrypt = AESIVUtil.decrypt(password, getIv());
        return decrypt;
    }

}
